package com.tang.future;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

/**
 * 一个Map
 *
 * @author fulin.tang
 * @version V3.0
 * @since 2022/5/19 12:24
 */
public class SyncWriteMap {

    private static SyncWriteMap instance;

    public Map<String, WriteFuture<?>> syncKey;

    private SyncWriteMap() {
        syncKey = new ConcurrentHashMap<>();
    }

    public static SyncWriteMap getInstance() {
        if (null != instance) return instance;
        Lock lock = new ReentrantLock();
        lock.lock();
        try {
            if (null == instance) {
                instance = new SyncWriteMap();
            }
        } finally {
            lock.unlock();
        }
        return instance;
    }

}
